-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L2 Cache retry initial commit #1046
Conversation
I think this direction is good |
@@ -82,6 +82,12 @@ protected override async Task RemoveKeyAsync(string cacheKey) | |||
catch (Exception ex) | |||
{ | |||
_logger.LogError($"[IdWebCache] Connection issue encountered with Distributed cache. Currently using In Memory cache only. Error message: {ex.Message} "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently using In Memory cache only [](start = 101, length = 36)
Forgot to mention this last time...
Replace: Remove cache entry for (key) failed. Don't have to mention anything about the memory cache here.
(same comment a few other places)
#Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done & i agree...was more for testing too to see where we were.
In reply to: 587807465 [](ancestors = 587807465)
if (_distributedCacheOptions.OnL2CacheFailure != null && _distributedCacheOptions.OnL2CacheFailure(ex)) | ||
{ | ||
_logger.LogDebug($"[IdWebCache] DistributedCache: Retry to remove cacheKey {cacheKey}. "); | ||
await _distributedCache.RemoveAsync(cacheKey).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await _distributedCache.RemoveAsync(cacheKey).ConfigureAwait(false); [](start = 20, length = 68)
have to catch this one as well #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -82,6 +82,12 @@ protected override async Task RemoveKeyAsync(string cacheKey) | |||
catch (Exception ex) | |||
{ | |||
_logger.LogError($"[IdWebCache] Connection issue encountered with Distributed cache. Currently using In Memory cache only. Error message: {ex.Message} "); | |||
|
|||
if (_distributedCacheOptions.OnL2CacheFailure != null && _distributedCacheOptions.OnL2CacheFailure(ex)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good pattern to apply everywhere. Try/catch can be refactored into a method/generic which takes an action #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Usage of timer/ticks/time spend can be wrapped up in a helper. Allowing you to have time since method start as well as time for each operation of needed. Also you have now one more place where you want to put timing data into the log. Can also consider adding the total call time for the method. #Resolved Refers to: src/Microsoft.Identity.Web/TokenCacheProviders/Distributed/MsalDistributedTokenCacheAdapter.cs:73 in 92fdc0e. [](commit_id = 92fdc0e, deletion_comment = False) |
i've used the Measure() static method for this instead. In reply to: 790928037 [](ancestors = 790928037) Refers to: src/Microsoft.Identity.Web/TokenCacheProviders/Distributed/MsalDistributedTokenCacheAdapter.cs:73 in 92fdc0e. [](commit_id = 92fdc0e, deletion_comment = False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @jennyf19. Awesome feature.
I tried it out with the Redis cache. It works great.
src/Microsoft.Identity.Web/TokenCacheProviders/Distributed/MsalDistributedTokenCacheAdapter.cs
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. |
Fixes #1042 1042
-TODO - needs testing and further work, just to start discussion